Missing Fonts When Printing from the Cloud

Description

This Section Describes how to install temporary fonts during a report generation when trying to render a report with a font that is not pre-installed on Alpha Cloud.

  1. Create a fonts folder under the web project.

  2. From the Web Control Panel, click All Files and then select File/New Folder from the window menu.

  3. Enter "Fonts" as the name of the folder and add the folder.

    It should show up as a folder on the Web Control Panel.

  4. Manually add each of the fonts you want to make available into the Fonts folder.

  5. Add the scripts below to your Xbasic web project code as described above (adjust the font names to match those fonts you want to install).

  6. Republish and deploy your web project to Alpha Cloud.

Add a snippet of code to Xbasic sometime before your report is printed.

The code shows an example of installing the Arial Narrow Fonts, You will need to change the code to reflect the specific fonts you copied into the fonts folder.

if Context.ApplicationConfiguration.ServerProduct = "AlphaCloud"
                dim sv as dotnet::Services
                dim ay as dotnet::assemblyreference
                ay.Name = "System.Drawing"
                ay.Version = "4.0.0.0"
                ay.Culture = "neutral"
                ay.PublicKeyToken = "b03f5f7f11d50a3a"
                if sv.registerassembly("::", ay)

                                dim pfc as System::Drawing::Text::PrivateFontCollection 

                                on error goto added
                                pfc.AddFontFile(Context.Request.ApplicationRoot + "\fonts\arialn.ttf")
                                pfc.AddFontFile(Context.Request.ApplicationRoot + "\fonts\arialnb.ttf")
                                pfc.AddFontFile(Context.Request.ApplicationRoot + "\fonts\arialnbi.ttf")
                                pfc.AddFontFile(Context.Request.ApplicationRoot + "\fonts\arialni.ttf")
                                pfc.AddFontFile(Context.Request.ApplicationRoot + "\fonts\arialuni.ttf")
                end if
added:
end if
You must run this on each request as it may not be saved between requests.